home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
XALL.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-01-05
|
21KB
|
367 lines
PAGE 60,132
TITLE Xall - High speed eXeute in ALL subdirs utility
SUBTTL General Program description
;-----------------------------------------------------------------------------;
; Xall - eXecute any command in current directory plus all subdirectories ;
;-----------------------------------------------------------------------------;
; XALL 1.0 ■ PCDATA TOOLKIT Copyright (c) 1990 Ziff Communications Co. ;
; PC Magazine ■ Wolfgang Stiller ;
; ;
;-----------------------------------------------------------------------------;
;Purpose: ;
; XALL will eXecute any command in the current directory plus all ;
; subdirectories below that one. This program is written for high ;
; speed execution (lean and mean!). ;
;-----------------------------------------------------------------------------;
;Syntax: ;
; ;
;XALL anyDOScommand ;
; ;
; "anyDOScommand" may be any batch file, program, or DOS command. Any ;
; programs or batch files should be located in a ;
; directory specified in the DOS path (PATH=). ;
;-----------------------------------------------------------------------------;
;Remarks: ;
; "anyDOScommand" will be executed first in the current directory and ;
; then in each subdirectory subordinate to the current directory. This ;
; program has been optimized for speed and efficiency of execution. If ;
; execution is terminated, you will be in the directory currently being ;
; processed. This program does NOT check for execution of other ;
; programs that change the drive or directory. (Speed is the goal!) ;
; XALL has advanced error recovery and provides clear explanations to ;
; PCDATA Toolkit user of what has gone wrong, such as an ;
; invalid COMSPEC environment variable. ;
; ;
; XALL will return the following DOS errorlevels: ;
; ;
; 00 - normal completion ;
; 32 - any abnormal occurance - indicates fatal termination. ;
;-----------------------------------------------------------------------------;
;-----------------------------------------------------------------;
; Constants: ;
;-----------------------------------------------------------------;
BOX EQU 254 ;Small box character code
CR EQU 0Dh ; Carriage return
LF EQU 0Ah ; Line feed
CRLF EQU 0A0D ; CR+LF in one word
First_time EQU 00h ; Constant to indicate first time
Not_First_Time EQU 0FFh ; indicate NOT first time
Subdirectory_attrib EQU 10h ; Bit pattern to find directories
CSEG SEGMENT
ASSUME CS:CSEG, DS:CSEG,ES:CSEG,SS:CSEG
ORG 2Ch ;Segment of environment found here
Environment LABEL BYTE
ORG 7DH ;Just before paramter area in PSP
XALL_PARM LABEL BYTE
ORG 80h ;Normal DOS PSP parameter area
PSP_PARM LABEL BYTE
;*****************************************************************************
;** Main program begins here: XALL - Subdirectory Command eXecuter **
;** ---- **
;*****************************************************************************
ORG 100h ;This is a .COM type program
XALL:
MOV SP,OFFSET STACK_TOP ;Create new stack
MOV DX,OFFSET XALL_CR_MSG ;Copyright message
MOV AH,09h ;DOS print string function
INT 21h
MOV BX,offset Program_top ;End of program + 15 (segment roundng)
MOV CX,4 ;Prepare to div by 4 (calc # of paras)
SHR BX,CL ;Convert to segment address
MOV AH,4Ah ;Release uneeded memory
INT 21h
CALL Get_COMSPEC ;Locate the compsec in the environment
CALL Create_EXEC_parm_BLOCK ;Create parameter block for DOS EXEC
CALL Create_Command_tail ;Create /C command for COMMAND.COM
;***********************;
; MAIN loop begins here ;
;***********************;
EXEC_Next_Command: ;Come here to execute a command
;in each directory
CALL DISPLAY_XALL_MSG ;Display msg that we are this directry
;---------------------------------------------------------------------------;
; Use DOS EXEC function to invoke COMMAND.COM with user's specified command ;
; tail from the parameter area at 80h. ;
LDS DX,[Command_Adr] ;DS:DX is address of command.com str
MOV BX,OFFSET Parm_block ;ES:BX is adr of parameter block
MOV AX,4b00h ;DOS EXEC sub-task function
INT 21h ;COMMAND.COM now executing user's cmd
; Return from execution of DOS shell - all registers may be corrupted:
MOV AX,CS ;CS is only OK register
MOV ES,AX
MOV DS,AX
MOV SS,AX
MOV SP,OFFSET Stack_top ;Reset stack pointer
JC Handle_Exec_Error ;If DOS EXEC function failed handle it
;-----------------------------------------------------------------------------;
; Now find NEXT (or first) subdirectory below the current one ;
;-----------------------------------------------------------------------------;
Find_another_SubDirectory:
MOV DX,[DTA_Ptr] ;Tell DOS to use different DTA
MOV AH,1Ah ;DOS set DTA function
INT 21h
CMP FF_Flag,First_time ;Is this first time in this directory?
JNE Find_next ; IF not, do a find next
MOV DX,OFFSET Global_str ; Else do an initial find on *.*
MOV CX,Subdirectory_attrib ; find only subdirectories
MOV AH,4Eh ; DOS FIND 1st function
INT 21h
JMP SHORT Validate_directory ;Skip the FIND NEXT function call
Find_Next: ;Find the next directory
MOV AH,4Fh ;DOS find next function
INT 21h
Validate_directory: ;Check that we found valid directory
JC Return_to_Mother ;If find failed, Return to mother dir
MOV DI,[DTA_Ptr] ;Get address of current DTA
; Check the file attribute bits in the DTA (is it a directory or a file?)
TEST BYTE PTR [DI+21],Subdirectory_attrib ;Is this a directory?
JE Find_Next ;If its not a directory keep looking
ADD DI,30 ;Point to directory name in DTA
CMP BYTE PTR [DI],'.' ;IS it a '.' or '..' dir e